class AccountsController < ApplicationController
  
  skip_before_filter :check_user_logged, 
                     :redirect_if_not_active,
                     :set_time_zone
                     
  def new
    @user = User.new(:email => params[:email])
    
    render :layout => "one_column"
  end
  
  def create
    @user = User.first(:conditions => {:email => params[:account][:email]})
    
    params[:account][:active] = true
    
    if @user
      @user.update_attributes(params[:account])
    else
      @user = User.new(params[:account])
    end
    
    if @user.save
      Delayed::Job.enqueue WelcomeMailerJob.new(@user.id, params[:account][:password])
      redirect_to root_path
    else
      render :action => "new"
    end
  end
end
